package com.xneure.code.upload;

import java.math.BigDecimal;

public class UploadMsg {
	private boolean succeed = false;
	private String msg;
	private long receiveSize = -1;
	private Object param;
	private long fileSize;
	private double progress;

	public long getFileSize() {
		return fileSize;
	}

	public void setFileSize(long fileSize) {
		this.fileSize = fileSize;
	}

	public double getProgress() {
		return progress;
	}

	public void setProgress(double progress) {
		this.progress = progress;
	}

	public boolean isSucceed() {
		return succeed;
	}

	public UploadMsg setSucceed(boolean succeed) {
		this.succeed = succeed;
		return this;
	}

	public String getMsg() {
		return msg;
	}

	public UploadMsg setMsg(String msg) {
		this.msg = msg;
		this.succeed = false;
		return this;
	}

	public long getReceiveSize() {
		return receiveSize;
	}

	public UploadMsg setReceiveSize(long fileSize) {
		this.receiveSize = fileSize;
		if (fileSize >= this.fileSize) {
			progress = 100;
		} else {
			BigDecimal b = new BigDecimal((fileSize / this.fileSize) * 100);
			progress = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
		}
		return this;
	}

	public Object getParam() {
		return param;
	}

	public UploadMsg setParam(Object param) {
		this.param = param;
		return this;
	}

}
